package com.aotain.project.apollo.app;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.aotain.common.CommonDB;
import com.aotain.common.DbPool;

public class IdcDao {


	private static IdcDao _instance;
	
	private DbPool dbPool = null;
	
	public IdcDao()
	{
		dbPool = new DbPool();
	}
	
	public static IdcDao getInstance()
	{
		if(_instance == null)
			_instance = new IdcDao();
		return _instance;
	}
	
	public List<String> getIdcNo() {
		List<String> list = new ArrayList<>();

		PreparedStatement pstmt = null;
		String sql = "select IDC from SDS_CFG_IDCINFO t ";
		ResultSet rs = null;
		Connection con = null;


		try {
			con = dbPool.getConn();
			con.setAutoCommit(false);
			pstmt = con.prepareStatement(sql);

			rs = pstmt.executeQuery();

			while(rs.next()) {
				String idcno = rs.getString("IDC");
				list.add(idcno);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	finally
		{
			CommonDB.closeDBConnection(con, pstmt, null);
		}


		return list;
	}
	
	
	public static void main(String[] args) {
		List<String> list = new ArrayList<String>();
		list = IdcDao.getInstance().getIdcNo();
		for(Iterator<String> iter = list.iterator();iter.hasNext();) {
			System.out.println(iter.next());
		}
	}
}
